package com.fjwt.gz.service.activity.game.acte008;

import com.fjwt.gz.core.utils.ExportExcelUtil;
import com.fjwt.gz.db.vo.AwardScoreVO;
import com.fjwt.gz.db.vo.ExportAwardVO;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.util.List;

public class ACTE008ExportExcle {

    /**
     * 其他卡券奖品信息
     * @param remark
     * @param workbook
     * @param list
     */
    public static void createCouponSheet(String remark,XSSFWorkbook workbook,List<ExportAwardVO> list){
        //2.创建一个sheet
        XSSFSheet sheet = workbook.createSheet(remark+"券奖品");
        String[] str = {"客户id","参与客户姓名","参与客户手机号","参与客户是否实名","领用卡券名称","卡券金额","微信唯一卡券编号","参与时间","核销时间","卡券状态",
                "参与客户归属网点机构号","参与客户归属网点名称","参与客户归属区县机构号","参与客户归属区县机构名称"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        sheet.setColumnWidth(10,8000);
        sheet.setColumnWidth(11,8000);
        sheet.setColumnWidth(12,8000);
        sheet.setColumnWidth(13,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }
        for(ExportAwardVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getCouponName());
            row2.createCell(5).setCellValue(s.getCouponPrice());
            row2.createCell(6).setCellValue(s.getCouponThirdId());
            row2.createCell(7).setCellValue(s.getCreatedAt());
            row2.createCell(8).setCellValue(s.getWriteTime());
            row2.createCell(9).setCellValue(s.getStatus());
            row2.createCell(10).setCellValue(s.getAgentNo());
            row2.createCell(11).setCellValue(s.getAgentName());
            row2.createCell(12).setCellValue(s.getSuperAgentNo());
            row2.createCell(13).setCellValue(s.getSuperAgentName());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(cellStyle);
            row2.getCell(6).setCellStyle(cellStyle);
            row2.getCell(7).setCellStyle(style);
            row2.getCell(8).setCellStyle(style);
            row2.getCell(9).setCellStyle(cellStyle);
            row2.getCell(10).setCellStyle(cellStyle);
            row2.getCell(11).setCellStyle(cellStyle);
            row2.getCell(12).setCellStyle(cellStyle);
            row2.getCell(13).setCellStyle(cellStyle);
        }
    }

    /**
     * 实物奖品信息
     * @param remark
     * @param workbook
     * @param list
     */
    public static void createGoodsSheet(String remark,XSSFWorkbook workbook,List<ExportAwardVO> list){
        XSSFSheet sheet = workbook.createSheet(remark+"券奖品");
        String[] str = {"客户id","参与客户姓名","参与客户手机号","参与客户是否实名","领用卡券名称","卡券金额","参与时间","核销时间","卡券状态",
                "参与客户归属网点机构号","参与客户归属网点名称","参与客户归属区县机构号","参与客户归属区县机构名称"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        sheet.setColumnWidth(10,8000);
        sheet.setColumnWidth(11,8000);
        sheet.setColumnWidth(11,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }

        for(ExportAwardVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getGoodsName());
            row2.createCell(5).setCellValue(s.getCouponPrice());
            row2.createCell(6).setCellValue(s.getCreatedAt());
            row2.createCell(7).setCellValue(s.getWriteTime());
            row2.createCell(8).setCellValue(s.getStatus());
            row2.createCell(9).setCellValue(s.getAgentNo());
            row2.createCell(10).setCellValue(s.getAgentName());
            row2.createCell(11).setCellValue(s.getSuperAgentNo());
            row2.createCell(12).setCellValue(s.getSuperAgentName());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(cellStyle);
            row2.getCell(6).setCellStyle(style);
            row2.getCell(7).setCellStyle(style);
            row2.getCell(8).setCellStyle(cellStyle);
            row2.getCell(9).setCellStyle(cellStyle);
            row2.getCell(10).setCellStyle(cellStyle);
            row2.getCell(11).setCellStyle(cellStyle);
            row2.getCell(12).setCellStyle(cellStyle);
        }
    }

    public static void createScoreSheet(XSSFWorkbook workbook,List<AwardScoreVO> list){
        //2.创建一个sheet
        String sheetName = "福分奖品";
        int index = 1;
        String uniqueSheetName = sheetName;

        while (workbook.getSheet(uniqueSheetName) != null) {
            uniqueSheetName = sheetName + "_" + index++;
        }
        XSSFSheet sheet = workbook.createSheet(uniqueSheetName);
        String[] str={"客户id","参与客户姓名","参与客户手机号","参与客户是否实名","福分值","参与时间","参与客户归属网点机构号","参与客户归属网点名称","参与客户归属区县机构号","参与客户归属区县机构名称"};
        XSSFCellStyle cellStyle = ExportExcelUtil.cellStyle(workbook);
        CellStyle style = ExportExcelUtil.dateCellStyle(workbook);
        sheet.setColumnWidth(0,2000);
        sheet.setColumnWidth(1,5000);
        sheet.setColumnWidth(2,8000);
        sheet.setColumnWidth(3,8000);
        sheet.setColumnWidth(4,8000);
        sheet.setColumnWidth(5,8000);
        sheet.setColumnWidth(6,8000);
        sheet.setColumnWidth(7,8000);
        sheet.setColumnWidth(8,8000);
        sheet.setColumnWidth(9,8000);
        //行号
        int rowNum = 0;
        XSSFRow row = sheet.createRow(rowNum++);
        for(int i=0;i<str.length;i++){
            row.createCell(i).setCellValue(str[i]);
            row.getCell(i).setCellStyle(cellStyle);
        }
        for(AwardScoreVO s:list){
            XSSFRow row2 = sheet.createRow(rowNum++);
            row2.createCell(0).setCellValue(s.getFansId());
            row2.createCell(1).setCellValue(s.getRealName());
            row2.createCell(2).setCellValue(s.getPhone());
            row2.createCell(3).setCellValue(s.getIsAuth());
            row2.createCell(4).setCellValue(s.getScore());
            row2.createCell(5).setCellValue(s.getCreateTime());
            row2.createCell(6).setCellValue(s.getAgentNo());
            row2.createCell(7).setCellValue(s.getAgentName());
            row2.createCell(8).setCellValue(s.getSuperAgentNo());
            row2.createCell(9).setCellValue(s.getSuperAgentName());

            row2.getCell(0).setCellStyle(cellStyle);
            row2.getCell(1).setCellStyle(cellStyle);
            row2.getCell(2).setCellStyle(cellStyle);
            row2.getCell(3).setCellStyle(cellStyle);
            row2.getCell(4).setCellStyle(cellStyle);
            row2.getCell(5).setCellStyle(style);
            row2.getCell(6).setCellStyle(cellStyle);
            row2.getCell(7).setCellStyle(cellStyle);
            row2.getCell(8).setCellStyle(cellStyle);
            row2.getCell(9).setCellStyle(cellStyle);
        }
    }
}
